const http = require('http');
const url = require('url')
let serve = http.createServer((req, res) => {
    res.setHeader('content-type','text/html;charset=utf-8')
    let { method } = req;
    let { pathname } = new URL(req.url, 'http://127.0.0.1');
    console.log('mmm',method,pathname);
    if (method == 'GET' && pathname == '/login') {
        res.end('登录页面')
    } else if (method == 'GET' && pathname == '/reg') {
        res.end('注册页面')
    } else {
        res.end('not found')
    }
})

serve.listen(1086, () => {
    console.log('服务开启成功');
})